package requests

import (
	"github.com/gin-gonic/gin"
	"github.com/thedevsaddam/govalidator"
)

type ZoneRequest struct {
	Title  string `valid:"title" json:"title"`
	Sort   int8   `valid:"sort" json:"sort"`
	Status int8   `valid:"status" json:"status"`
}

func ZoneStore(data interface{}, c *gin.Context) map[string][]string {

	rules := govalidator.MapData{
		"title":  []string{"required", "min:1", "max:40"},
		"sort":   []string{"numeric"},
		"status": []string{"in:1,2"},
	}
	messages := govalidator.MapData{
		"title": []string{
			"required:标题为必填项",
			"min:标题长度需大于 1",
			"max:标题长度需小于 40",
		},
		"sort": []string{
			"numeric:排序取值不合法",
		},
		"status": []string{
			"in:状态取值不合法",
		},
	}

	return validate(data, rules, messages)
}
